<?php

namespace app\services\posts;

use app\dao\posts\PostCommentsDao;
use app\dao\posts\PostsDao;
use app\services\BaseServices;

/**
 * 帖子评论
 */
class PostCommentsServices extends BaseServices
{
    public function __construct(PostCommentsDao $dao)
    {
        $this->dao = $dao;
    }

    public function getList(array $where)
    {
        [ $page, $limit ] = $this->getPageValue();
        $query = $this->dao->search($where);
        $count = $query->count();
        $dataList = $query->with('userIdHasOne')->page($page, $limit)->order('parent_id','desc')->select()->toArray();
        return compact('dataList', 'count');
    }

    public function pageListAdmin(array $where)
    {
        [ $page, $limit ] = $this->getPageValue();
        $query = $this->dao->search($where);
        $count = $query->count();
        $dataList = $query->with(['user'])->page($page, $limit)->select()->toArray();
        return compact('dataList', 'count');
    }
}